//
//  XZSelectSignView.m
//  Teecloud
//
//  Created by PC on 2018/11/19.
//  Copyright © 2018年 小志. All rights reserved.
//

#import "XZSelectSignView.h"

@interface XZSelectSignView()
@property (weak, nonatomic) IBOutlet UIView *alertView;
@end

@implementation XZSelectSignView
- (void)awakeFromNib{
    [super awakeFromNib];
    UITapGestureRecognizer  *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hideView)];
    [self addGestureRecognizer:tap];
}
- (void)show{
    [UIView animateWithDuration:0.25 animations:^{
        UIWindow *rootWindow = [UIApplication sharedApplication].keyWindow;
        [rootWindow addSubview:self];
        [self animationAlert:self.alertView];
    }];
}

- (void)hide{
    [UIView animateWithDuration:0.25 animations:^{
        [self removeFromSuperview];
    }];
    
}
- (void)hideView{
    [UIView animateWithDuration:0.25 animations:^{
        [self removeFromSuperview];
    }];
}
- (void)animationAlert:(UIView *)view
{
    CAKeyframeAnimation *popAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
    popAnimation.duration = 0.4;
    popAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.01f, 0.01f, 1.0f)],
                            [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1f, 1.1f, 1.0f)],
                            [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9f, 0.9f, 1.0f)],
                            [NSValue valueWithCATransform3D:CATransform3DIdentity]];
    popAnimation.keyTimes = @[@0.0f, @0.5f, @0.75f, @1.0f];
    popAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
                                     [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
                                     [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
    [view.layer addAnimation:popAnimation forKey:nil];
    
}
- (IBAction)signInTapAction:(UITapGestureRecognizer *)sender {
    if (self.signInOrOutBlock) {
        self.signInOrOutBlock(@"signIn");
    }
}
- (IBAction)signOutTapAction:(UITapGestureRecognizer *)sender {
    if (self.signInOrOutBlock) {
        self.signInOrOutBlock(@"signOut");
    }
}



@end
